#include <iostream>
#include <queue>
#include <algorithm>
#define MAXN 100005
#define INF 1 << 29
using namespace std;
typedef pair<int, int> Cow;
int N, C, F;
int lower[MAXN], upper[MAXN];
Cow cows[MAXN];
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin >> N >> C >> F;
    for (int i = 0; i < C; i++) {
        cin >> cows[i].first >> cows[i].second;
    }
    solve();
}

void solve() {
    sort(cows, cows + C);
    priority_queue<int> q;
    int total = 0, half = N / 2;
    for (int i = 0; i < C; i++) {
        lower[i] = (q.size() == half ? total : INF);
        q.push(cows[i].second); total += cows[i].second;
        if (q.size() > half) {
            int f = q.top(); total -= f;
            q.pop();
        }
    }

    priority_queue<int> qm;
    total = 0;
    for (int i = C - 1; i >= 0; i--) {
        upper[i] = (qm.size() == half ? total : INF);
        qm.push(cows[i].second); total += cows[i].second;
        if (qm.size() > half) {
            int f = qm.top(); total -= f;
            qm.pop();
        }
    }

    int ans = -1;
    for (int i = C - 1; i >= 0; i--) {
        if (lower[i] + upper[i] + cows[i].second <= F) {
            ans = cows[i].first;
            break;
        }
    }
    cout << ans << endl;
}


